#include<iostream>
#include<string>
using namespace std;
const int N = 1e5 + 10;
string s;
int n;


int main()
{
	cin >> s;
	cin >> n;
	int cnt = 0;
	while (n--) {
		cnt++;
		//13
		//1113
		string t;
		//cout << "ss---->" << s << endl;
		//1113
		for (int i = 0; i < s.size(); i++) {
			int ans = 0;
			int j = i + 1;
			while (j < s.size() && s[i] == s[j])j++;
			//cout << "jjjj->" << j << endl;
			ans = j - i;
			
			cout << ans << s[i] - '0';
			t += to_string(ans);
			t += to_string(s[i] - '0');
			i = j - 1;
		}
		//cout << "tttt----" << t << endl;
		s = t;
		if (n == 1) {
			cout << s << endl;
		}
		cout << endl;
	}
	return 0;
}